<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/2/20
 * Time: 8:36
 */
namespace app\admin\controller;


use think\Db;
use think\Request;
class About extends Base {
    /**
     * 注册协议
     * @return mixed|\think\response\Json
     */
    public function index(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 1)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 1)->value('content');
        $this->assign('content', $about_content);
        return $this->fetch('about/zhuce');
    }

    /**
     * 隐私协议
     * @return mixed|\think\response\Json
     */

    public function yinsi(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 2)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 2)->value('content');
        $this->assign('content', $about_content);
        return $this->fetch('about/yinsi');
    }
    /**
     * 关于我们
     * @return mixed|\think\response\Json
     */
    public function about(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 3)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 3)->value('content');
        $this->assign('content', $about_content);
        return $this->fetch('about/about');
    }
    /**
     * 24小时服务热线
     * @return mixed|\think\response\Json
     */
    public function mypage(){
        if(Request::instance()->isPost()){
            $about_content = input('content');
            $aaa = input('aaa');
            $res = Db::table('up_about')->where('id', 4)->update(['content' => $about_content]);
            $res = Db::table('up_about')->where('id', 6)->update(['content' => $aaa]);
            return json(['code' => 200, 'msg' => '保存成功']);
        }
        $about_content = Db::table('up_about')->where('id',4)->value('content');
        $aaa = Db::table('up_about')->where('id',6)->value('content');
        $this->assign('content', $about_content);
        $this->assign('aaa', $aaa);
        return $this->fetch('about/sizepic');
    }
	/**
     * 登录页背景图
     * @return mixed|\think\response\Json
     */
    public function loginPic(){
        if(Request::instance()->isPost()){
            $about_content = input('content');
            $res = Db::table('up_about')->where('id', 5)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id',5)->value('content');
        $this->assign('content', $about_content);
        return $this->fetch('about/loginpic');
    }
    /**
     * 登录页背景图
     * @return mixed|\think\response\Json
     */
    public function imgs(){
        if(Request::instance()->isPost()){
            $content1 = input('content1');
            $content2 = input('content2');
            $content3 = input('content3');
            $content4 = input('content4');
            $content5 = input('content5');
            $res = Db::table('up_about')->where('id', 10)->update(['content' => $content1]);
            $res = Db::table('up_about')->where('id', 11)->update(['content' => $content2]);
            $res = Db::table('up_about')->where('id', 12)->update(['content' => $content3]);
            $res = Db::table('up_about')->where('id', 13)->update(['content' => $content4]);
            $res = Db::table('up_about')->where('id', 23)->update(['content' => $content5]);
            return json(['code' => 200, 'msg' => '保存成功']);
        }
        $about_content = Db::table('up_about')->where('id','in','10,11,12,13,23')->column('content');
        $this->assign('content1', $about_content[0]);
        $this->assign('content2', $about_content[1]);
        $this->assign('content3', $about_content[2]);
        $this->assign('content4', $about_content[3]);
        $this->assign('content5', $about_content[4]);
        return $this->fetch('about/imgs');
    }
    /**
     * 推荐文案
     * @return mixed|\think\response\Json
     */
    public function tuijian(){
        if(Request::instance()->isPost()){
            $about_content1 = input('content1');
            $about_content2 = input('content2');
            $about_content3 = input('content3');
            $about_content4 = input('content4');
            $about_content5 = input('content5');
            $about_content6 = input('content6');
            $about_content7 = input('content7');
            $about_content8 = input('content8');
            $res = Db::table('up_about')->where('id', 7)->update(['content' => $about_content1]);
            $res = Db::table('up_about')->where('id', 8)->update(['content' => $about_content2]);
            $res = Db::table('up_about')->where('id', 9)->update(['content' => $about_content3]);
            $res = Db::table('up_about')->where('id', 25)->update(['content' => $about_content4]);
            $res = Db::table('up_about')->where('id', 27)->update(['content' => $about_content5]);
            $res = Db::table('up_about')->where('id', 28)->update(['content' => $about_content6]);
            $res = Db::table('up_about')->where('id', 33)->update(['content' => $about_content7]);
            $res = Db::table('up_about')->where('id', 34)->update(['content' => $about_content8]);
            return json(['code' => 200, 'msg' => '保存成功']);
        }
        $about_content = Db::table('up_about')->where('id','in','7,8,9,25,27,28,33,34')->column('content');
        $this->assign('content1', $about_content[0]);
        $this->assign('content2', $about_content[1]);
        $this->assign('content3', $about_content[2]);
        $this->assign('content4', $about_content[3]);
        $this->assign('content5', $about_content[4]);
        $this->assign('content6', $about_content[5]);
        $this->assign('content7', $about_content[6]);
        $this->assign('content8', $about_content[7]);
        return $this->fetch('about/tuijian');
    }
    /**
     * 推荐开关
     * @return mixed|\think\response\Json
     */
    public function openclose(){
        if(Request::instance()->isPost()){
            $about_content1 = input('content1');
            $about_content2 = input('content2');
            $about_content3 = input('content3');
            $about_content4 = input('content4');
            $about_content5 = input('content5');
            $about_content6 = input('content6');
            $about_content7 = input('content7');
            $about_content8 = input('content8');
            $res = Db::table('up_about')->where('id', 15)->update(['content' => $about_content1]);
            $res = Db::table('up_about')->where('id', 16)->update(['content' => $about_content2]);
            $res = Db::table('up_about')->where('id', 17)->update(['content' => $about_content3]);
            $res = Db::table('up_about')->where('id', 26)->update(['content' => $about_content4]);
            $res = Db::table('up_about')->where('id', 29)->update(['content' => $about_content5]);
            $res = Db::table('up_about')->where('id', 30)->update(['content' => $about_content6]);
            $res = Db::table('up_about')->where('id', 31)->update(['content' => $about_content7]);
            $res = Db::table('up_about')->where('id', 32)->update(['content' => $about_content8]);
            return json(['code' => 200, 'msg' => '保存成功']);
        }
        $about_content = Db::table('up_about')->where('id','in','15,16,17,26,29,30,31,32')->column('content');
        $this->assign('content1', $about_content[0]);
        $this->assign('content2', $about_content[1]);
        $this->assign('content3', $about_content[2]);
        $this->assign('content4', $about_content[3]);
        $this->assign('content5', $about_content[4]);
        $this->assign('content6', $about_content[5]);
        $this->assign('content7', $about_content[6]);
        $this->assign('content8', $about_content[7]);
        return $this->fetch('about/openclose');
    }
    /**
     * 设计师显示开关
     * @return mixed|\think\response\Json
     */
    public function useropen(){
        if(Request::instance()->isPost()){
            $about_content1 = input('content1');
            $about_content2 = input('content2');
            $about_content3 = input('content3');
            $about_content4 = input('content4');
            $res = Db::table('up_about')->where('id', 18)->update(['content' => $about_content1]);
            $res = Db::table('up_about')->where('id', 21)->update(['content' => $about_content2]);
            $res = Db::table('up_about')->where('id', 22)->update(['content' => $about_content3]);
            $res = Db::table('up_about')->where('id', 24)->update(['content' => $about_content4]);
            return json(['code' => 200, 'msg' => '保存成功']);
        }
        $about_content1 = Db::table('up_about')->where('id',18)->value('content');
        $about_content2 = Db::table('up_about')->where('id',21)->value('content');
        $about_content3 = Db::table('up_about')->where('id',22)->value('content');
        $about_content4 = Db::table('up_about')->where('id',24)->value('content');
        $this->assign('content1', $about_content1);
        $this->assign('content2', $about_content2);
        $this->assign('content3', $about_content3);
        $this->assign('content4', $about_content4);
        return $this->fetch('about/useropen');
    }
    /**
     * 设计师显示开关
     * @return mixed|\think\response\Json
     */
    public function alluseropen(){
        if(Request::instance()->isPost()){
            $about_content1 = input('content1');
            $about_content2 = input('content2');
            if($about_content1 != 3) Db::table('up_about')->where('id', 19)->update(['content' => $about_content1]);
            if($about_content2 != 3) Db::table('up_about')->where('id', 20)->update(['content' => $about_content2]);
            $update = [];
            if($about_content1 == 1) $update['user_d_auth_uids'] = '';
            if($about_content1 == 2) $update['user_d_auth_uids'] = -1;
            if($about_content2 == 1) $update['user_d_auth_sids'] = '';
            if($about_content2 == 2) $update['user_d_auth_sids'] = -1;
            if($update){
                $res = Db::table('up_u_user')
                    ->where('user_id', '>',0)
                    ->update($update);
            }
            return json(['code' => 200, 'msg' => '保存成功']);
        }
        $about_content = Db::table('up_about')->where('id',19)->value('content');
        $about_content2 = Db::table('up_about')->where('id',20)->value('content');
        $this->assign('content1', $about_content);
        $this->assign('content2', $about_content2);
        return $this->fetch('about/alluseropen');
    }
}